<template>
	<!-- 头部导航栏 -->
	<view style="
	border-bottom: solid 1rpx #eee;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 28rpx 20rpx;
	position:fixed;
	top:0;left:0;right:0;
	height: 60px;
	z-index: 22;
	background-color: white;
	">
		<view style="display: flex;position: absolute;z-index: 22;" @click="back">
			<u-icon name="arrow-left"></u-icon>
			<view>返回</view>
		</view>
		
		<view style="font-weight: bold;position: absolute;left: 0;right: 0;height: 100%;display: flex;align-items: center;justify-content: center;">
			发表预览
		</view>
	</view>
	 
	<view style="margin: 0 0rpx;box-sizing: border-box;padding-top: 60px;">
		<mp-html :content="html" :tag-style="{boxSizing:'border-box'}" style="box-sizing: border-box;" />
		<!-- <web-view :webview-styles="{with:'100%'}" fullscreen src="http://www.apesk.net/api/common/wx/get_published"></web-view> -->
	</view>
	
	<view style="padding-top: 60px;"></view>
	
	<view @click="showComfirmModal=true" style="
		position: fixed;bottom: 0;
		left:0;right:0;
		height: 60px;
		display: flex;
		align-items: center;
		background-color: white;
		border-top: solid 1rpx #eee;
		"
	>
		<view @click="showComfirmModal=true" style="
			display: flex;
			justify-content: center;
			align-items: center;
			padding: 10rpx 0rpx;
			border-radius: 10rpx;
			box-shadow: 0 0 14px 0 #66666635;
			border: solid 1rpx #ddd;
			top:10px;bottom: 10px;left:10px;right: 10px; 
			position: absolute;
		">
				保存图文到草稿
		</view>
	</view>
	
	<u-modal
		:show="showComfirmModal" 
		title="保存确认" 
		content="是否保存草稿?" 
		cancel-text="取消" 
		show-cancel-button 
		@cancel="showComfirmModal=false"
		@confirm="onPublish"
	></u-modal>
	
</template>

<script>
	export default {
		async onLoad(){
			
			//小程序不支持 ejs ,换做服务器渲染  2023-11-24 @jason
			
			// this.template = await this.$http.get('http://www.apesk.net/static/template.ejs')
			// this.html = this.$ejs.render(this.template,{
   //          labels:[
   //              ''
   //          ],
			
			// tasks: this.$officePost.create.selected,
			
   //          // tasks:[
   //          //     {
   //          //         title:'ARE YOU OK?',
   //          //         start_date:'sdfsdf',
   //          //         price:16,
   //          //         price_unit:'HAHA',
   //          //         address:'答辩3',
   //          //         comment:'有意向的同学,立即添加微信,长期做的有更多福利<br/>微信号: xiaoyan265478 飞机勿扰,谢谢!'
   //          //     },
   //          //     {
   //          //         title:'ARE YOU OK?23',
   //          //         start_date:'sdfsdf-2',
   //          //         price:17,
   //          //         price_unit:'HAHA-2',
   //          //         address:'答辩-2',
   //          //         comment:'有意向的同学,立即添加微信,长期做的有更多福利<br/>微信号: xiaoyan265478 飞机勿扰,谢谢!-2'
   //          //     }
   //          // ]
   //      })
		
		console.log(this.$officePost.create.selected)
   
			// const res = await this.$http.get('/common/wx/html?id=1')
			// this.html = res.data.html
		},
		data() {
			return {
				showComfirmModal:false,
				template:'',
				html:''
			}
		},
		methods: {
			back(){
				uni.navigateBack()
			},
			async onPublish(){
				this.showComfirmModal = false
				// console.log('???')
				// const res = await this.$http.post('/common/wx/html',{
				// 	html:this.html
				// })
				
				// console.log(res)
				
				this.$officePost.create.createPost.html = this.html

				uni.navigateTo({
					url: '/pages/job/publish/job-offices/mp-preview/post-form'
				})

				// uni.navigateBack({
				// 	delta: 2
				// })
				
				// var str = this.html.replaceAll(/(<[^>]*>)/g,'').replaceAll(/[\s\n]/g,'')
				// console.log(str)
				// str = str.substr(0,50)
				// console.log(str)
				
				//this.$officePost.ackCreateOK()
			}
		}
	}
</script>

<style>

</style>
